package com.bd.scm.domain.dto.user;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @BelongsProject: bd-scm
 * @BelongsPackage: com.bd.scm.domain.dto.user
 * @Author: yu_0hong
 * @CreateTime: 2020-02-20 18:04
 * @Description: A
 */
public class A {

    /**
     * 汉语中数字大写
     */
    private static final String[] CN_UPPER_NUMBER = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" };

    public  static String numToUpper(char c) {
        char[] str = String.valueOf(c).toCharArray();
        String rstr = "";
        for(int i = 0; i < str.length; i++) {
            rstr = rstr + CN_UPPER_NUMBER[Integer.parseInt(str[i] + "")];
        }
        return rstr;
    }

    public static void main(String[] args) {
        //String str = "人民币200.0000万元整";
        //char[] aa =str.toCharArray();
        //String cc="";
        //String a="";
        //for (int i = 0; i < aa.length; i++) {
        //    if(aa[i]<='9'&&aa[i]>='0'){
        //        a= numToUpper(aa[i]);
        //    }else{
        //        a = ""+aa[i]+"";
        //    }
        //    cc+=a;
        //}
        //System.out.println(cc);
        //
        //System.out.println(toRMB(22220.0000));

        String str="人民币200.0000万元整";
        String regEx="\\D";
        Pattern p= Pattern.compile(regEx);
        Matcher m=p.matcher(str);
        String result=m.replaceAll("").trim();
        Character ch=result.charAt(0);
        int index=str.indexOf(ch);
        String diqu=str.substring(0,index);
        String riqi=str.substring(index,index+8);
        String riqi2=str.substring(index+8,str.length());
        System.out.println(diqu+"  ______  "+riqi+"   ________  "+riqi2);
    }

    public static String toRMB(double money) {
        char[] s1 = {'零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'};
        char[] s4 = {'分', '角', '元', '拾', '佰', '仟', '万', '拾', '佰', '仟', '亿', '拾', '佰', '仟', '万'};
        String str = String.valueOf(Math.round(money * 100 + 0.00001));
        String result = "";

        boolean zeroFlag = false;
        for (int i = 0; i < str.length(); i++) {
            int n = str.charAt(i) - '0';
            int level = str.length() - i - 1;
            if (n == 0) {
                zeroFlag = true;
                if (level % 4 == 2) {
                     //result += "" + s4[level];
                }
            } else {
                if (zeroFlag) {
                    //result += "零";
                    zeroFlag = false;
                }
                result += "" + s1[n] + s4[level];
                //result += "" + s1[n];
            }
        }

        //return result.replaceAll("亿万", "亿").replaceAll("元$", "元整");
        return result;
    }


}
